package com.ruoyi.project.tool.swagger.UserController;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.annotation.SignatureValidation;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.interceptor.annotation.RepeatSubmit;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.domain.SysUserParise;
import com.ruoyi.project.system.service.ISysUserPariseService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户动态点赞Controller
 *
 * @author jjp
 * @date 2020-04-16
 */
@RestController
@Api(description = "用户动态点赞")
@RequestMapping("/mobileUser/userParise")
public class UserUserPariseController extends BaseController {
    @Autowired
    private ISysUserPariseService sysUserPariseService;

    /**
     * 查询用户动态点赞列表
     */
    @GetMapping("/list")
    @SignatureValidation
    public TableDataInfo list(SysUserParise sysUserParise) {
        sysUserParise.setMobileUserId(SecurityUtils.getLoginUser().getSysMobileUser().getMobileUserId());
        startPage();
        List<SysUserParise> list = sysUserPariseService.selectSysUserPariseList(sysUserParise);
        return getDataTable(list);
    }


    /**
     * 获取用户动态点赞详细信息
     */
    @GetMapping(value = "/{pariseId}")
    @SignatureValidation
    public AjaxResult getInfo(@PathVariable("pariseId") Long pariseId) {
        return AjaxResult.success(sysUserPariseService.selectSysUserPariseById(pariseId));
    }

    /**
     * 新增用户动态点赞
     */
    @Log(title = "用户动态点赞", businessType = BusinessType.INSERT)
    @SignatureValidation
    @RepeatSubmit
    @PostMapping
    public AjaxResult add(@RequestBody SysUserParise sysUserParise) {
        sysUserParise.setMobileUserId(SecurityUtils.getLoginUser().getSysMobileUser().getMobileUserId());
        return toAjax(sysUserPariseService.insertSysUserParise(sysUserParise));
    }

    /**
     * 修改用户动态点赞
     */
    @Log(title = "用户动态点赞", businessType = BusinessType.UPDATE)
    @SignatureValidation
    @RepeatSubmit
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserParise sysUserParise) {
        sysUserParise.setMobileUserId(SecurityUtils.getLoginUser().getSysMobileUser().getMobileUserId());
        return toAjax(sysUserPariseService.updateSysUserParise(sysUserParise));
    }

    /**
     * 删除用户动态点赞
     */
    @Log(title = "用户动态点赞", businessType = BusinessType.DELETE)
    @DeleteMapping("/{pariseIds}")
    public AjaxResult remove(@PathVariable Long[] pariseIds) {
        return toAjax(sysUserPariseService.deleteSysUserPariseByIds(pariseIds));
    }


    /**
     * 查询用户动态点赞列表
     */
    @GetMapping(value = "/getDynamicIdInfo/{dynamicId}")
    @SignatureValidation
    public TableDataInfo getDynamicIdInfo(@PathVariable("dynamicId") Long dynamicId) {
        List<SysUserParise> list = sysUserPariseService.selectSysUserPariseByDynamicId(dynamicId);
        return getDataTable(list);
    }
}
